package com.example.demo.controller;

import com.example.demo.exception.MyException;
import com.example.demo.service.TestExceptionService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.io.FileNotFoundException;

@Controller
public class TestExceptionController {
    @Resource
    private TestExceptionService testExceptionService;
    @RequestMapping(value = "/errorShow")
    public String show() throws FileNotFoundException, MyException {

        /**
         * 人造异常 ————转换，空指针，notFind，除以0的异常
         * 进去后就会报异常  在service时候会被抛   抛给mvc框架解决
         *  MVC已经封装好异常处理机制了
         *  做到不跳转的前提下 到error
         */
        testExceptionService.show4();

        //自定义异常
//        testExceptionService.show5();
        return "index";
    }

}
